import pygame
import time
import hpbars
import move
#import RegularAndFlippedAttacks

battleScreenWidth = 256
battleScreenHeight = 144
POKESWITCHTICKS = 20
HEALTHBARTICKS = 60
BLACK = [0, 0, 0]
WHITE = [255, 255, 255]
PAUSETICKS = 15

###########################################################################################################
#"""
#  _____                    _______                     _____      _                                
# |  __ \                  |__   __|                   |  __ \    | |                               
# | |  | | ___  __ _ _ __     | | ___  __ _ _ __ ___   | |__) |__ | | _____ _ __ ___   ___  _ __    
# | |  | |/ _ \/ _` | '__|    | |/ _ \/ _` | '_ ` _ \  |  ___/ _ \| |/ / _ \ '_ ` _ \ / _ \| '_ \   
# | |__| |  __/ (_| | |       | |  __/ (_| | | | | | | | |  | (_) |   <  __/ | | | | | (_) | | | |_ 
# |_____/ \___|\__,_|_|       |_|\___|\__,_|_| |_| |_| |_|   \___/|_|\_\___|_| |_| |_|\___/|_| |_( )
#                                                                                                |/ 
#
#
#This code is really long and messy.  You should definitely refactor it.
#
#Love,
#Chris
#"""            
#########################################################################################################3
#
#'''Dear Chris, 
#
#This code isnt part of the game yet. Im working on integrating the animations with battle screen so there are more options for attack animations.
#Once I get a rough draft done of it I plan on making it shorter and more efficent.
#
#Spenser
#
# P.S. If you have any suggestions on how i can place the animations on the screen without the lengthy if, elif statements that
# would be really appreciated. Could i do it with a for statement? Currently im using the if elif because the coordinates are different for
# a lot of the animations.
#'''
############################################################################################################
#"""
#
#Dear Spenser,
#
#Part of the reason the code has gotten so long here is because it doesn't seem as though you're splitting these functions up into enough classes.  I would suggest a base class, call it attack.  It should have a few methods, such as "draw self" or "do battle effects".  Make the functions fairly specific in what they do.  Then, have each attack be a subclass of this base attack, each its own implementation of these methods.  Or better yet, have them have the same "draw self" and "do battle effects," and supply have the parameters stored inside of the it's own class.
#
#Let me get more concrete with this.  Let's say we had the base attack class I mentioned, I'll write a quick one below.  It probably won't work perfectly without a lot of work, as I don't completely understand how everything works right now, but hopefully you will get the idea.
#"""



#class Attack():
#	
#	def __init__(self):
#		pass
#	def drawAnimations(self, WhoIsAttacking, screen):
#		screen.blit(self.animation.getFrame(),self.animation.getAnimationCoords)
#		self.animation.advanceImage()
#	def doBattleEffects(self, player,opponent):
#		#note, that when this method is called, the attacking player must be set to "player" 
#		raise NotImplementedError
#	def paralyze(self, player, probability):
#		#use this class, along with similar other ones, to do battle effects
#		#set the opponent's active pokemon to be paralyzed
#		player.activePokemon.paralyzed = True #I have no idea how you guys are storing the information. But the way I'm accessing it is how I would expect it to be stored.
#
#class Thunderbolt(Attack):
#	def __init__(self):
#		Attack.__init__(self)
#		self.animations = Animations.load("path", spriteSheetLoaderParamsForAThunderboltAttack)
#		self.animations.setcoords(["<thunderbolt coords, whatever they are>"])
#	def doBattleEffects(self, player, opponent):
#		opponent.doDamage(self.damage) #or you might store the amount of damage in some database.  I think you guys already did that...
#		Attack.paralyze(opponent, probability)
#
#class Animation():
#	def __init__(self, path, spriteSheetLoaderParameters):
#		self.imageArray = loadSpriteSheet(path, spriteSheetLoaderParameters) #call whatever you need to in order to load this using your spritesheet loader"
#		self.imageNumber = 0
#	def getFrame(self):
#		return self.imageArray[self.imageNumber]
#	def getImageCoords(self):
#		return self.imageCoords[self.frame]
#	def advanceImage(self):
#		self.imageNumber += 1
#	
               
                                                                                  
#trainerOneImage = pygame.image.load('../images/')


class BattleScreen:
    isAttacking = False
    
    def __init__(self, play0, play1, tbox):
       self.battleScreen = pygame.Surface([battleScreenWidth, battleScreenHeight])
       
       self.backgroundImage = pygame.image.load("../images/BattleBackgrounds/background.png")
       
       self.secondBackgroundImage = pygame.image.load("../images/BattleBackgrounds/sprite5.png")
       self.secondBackgroundImage.set_colorkey([255, 255, 255])
       
       self.play = [play0, play1]
       self.hpBars = [hpbars.HPBar(0), hpbars.HPBar(1)]
       self.textbox = tbox
       
       self.hpBars[0].setNew(self.play[0].pokemon[self.play[0].activePoke].name, self.play[0].pokemon[self.play[0].activePoke].HP_stat[0], self.play[0].pokemon[self.play[0].activePoke].HP_stat[1], None)
       self.hpBars[1].setNew(self.play[1].pokemon[self.play[1].activePoke].name, self.play[1].pokemon[self.play[1].activePoke].HP_stat[0], self.play[1].pokemon[self.play[1].activePoke].HP_stat[1], None)
       
       self.pokeFrontImage = pygame.image.load('../images/fronts/' + str(self.play[1].pokemon[self.play[1].activePoke].ID) + '.png')#
       self.topPokePos = [192 - (self.pokeFrontImage.get_size()[0] / 2 ), 95 - (self.pokeFrontImage.get_size()[1])]
       
       self.pokeBackImage = pygame.image.load('../images/back/' + str(self.play[0].pokemon[self.play[0].activePoke].ID) + '.png')
       self.bottomPokePos = [64 - (self.pokeBackImage.get_size()[0] / 2), battleScreenHeight - (self.pokeBackImage.get_size()[1] / 1.5)]
       
       self.animationFrames = [10, 17, 23, 10, 30, 17, 17, 11, 14, 11, 11, 4, 13, 4]
       self.animationHeight = [144, 191, 191, 144, 144, 191, 144, 191, 191, 144, 191, 191, 191, 32]
       self.animationHeightv2 = [144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 32]
       self.animationWidth = [256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 32]
       self.animationRow = [10, 17, 23, 4, 30, 17, 17, 11, 14, 11, 11, 4, 13, 4]
       self.animationColumn = [1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
       ###############       0                 1                 2               3          4            5            6               7          8                9                 10             11              12         13
       self.animation = ['FIRE-BLAST-1', 'HYDRO-CANNON-2', 'SHADOW-BALL-1', 'Seed-Flare', 'SURFV2', 'MUD-SHOT-1', 'AEROBLAST-1', 'SWIFT-1', 'HYDRO-PUMP-1', 'FRENZY-PLANT-1', 'BLAST-BURN-1', 'WOOD-HAMMER-1', 'MUDSPORT', 'THUNDAR']
       self.animationBackground = ['fireblastybackground', 'Hydro-cannon-back', 'whiteBackground', 'whiteBackground', 'whiteBackground', 'whiteBackground', 'AeroBlastBackground', 'whiteBackground', 'whiteBackground', 'whiteBackground', 'whiteBackground', 'whiteBackground', 'whiteBackground', 'whiteBackground']
       self.animationColor = [BLACK, BLACK, BLACK, WHITE, WHITE, WHITE, BLACK, BLACK, BLACK, WHITE, BLACK, BLACK, WHITE, BLACK]
       ###############          0    1    2    3    4    5    6    7    8    9    10    11    12    13     14         15                16                 17               18               19              20            21         22         23           24        25        26           27             28               29                 30                   31               32 
       self.staticAnimation = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', 'Chop', 'Close_Combat', 'Dynamic-Punch1', 'Dynamic-Punch2', 'generic_Attack', 'Giga-Impact1', 'Giga-Impact2', 'Heat_Wave', 'Kick', 'Leaf_Storm', 'Psychic', 'punch', 'Scratch', 'ShadowClaw', 'Spacial_Rend1', 'Spacial_Rend2', 'Speed-Attack-Back','the_Generic_Attack', 'X-Scizzor']
       ###############
       self.currentAnim = "None"
       self.attackBackgroundImage = None
       self.attackForegroundImage = None
       ##########        0     1         2        3          4         5        6      7       8        9       10      11       12        13         14      15      16       17
       self.typeList = ["", "normal", "fight", "flying", "poison", "ground", "rock", "bug", "ghost", "steel", "fire", "water", "grass", "electr", "psychc", "ice", "dragon", "dark"]
       self.typeListNums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
    def display(self):
        self.battleScreen = pygame.Surface([battleScreenWidth, battleScreenHeight])
        self.battleScreen.blit(self.backgroundImage, [0, 0])
        self.battleScreen.blit(self.secondBackgroundImage, [0, 0])
        
        if(self.attackBackgroundImage != None):
            if OpponentAttack == True and self.animNum == 1:
                pygame.transform.flip(self.attackBackgroundImage, True, True)
            self.battleScreen.blit(self.attackBackgroundImage, [0, 0])
        
        self.battleScreen.blit(self.pokeFrontImage, self.topPokePos)
        self.battleScreen.blit(self.pokeBackImage, self.bottomPokePos)
        
        if(self.attackForegroundImage != None):
            if self.animNum <= 13:
                temp = self.attackForegroundImage
                temp.set_colorkey(self.animationColor[self.animNum])
                
                
##                if PlayerAttack == True:                    
##                    if self.animNum == 7:
##                        self.battleScreen.blit(temp, (-1, 40))
##                    elif self.animNum == 11:
##                        self.battleScreen.blit(temp, (2, 0))
##                    elif self.animNum == 12:
##                        self.battleScreen.blit(temp, (-2, -40))
##                    elif self.animNum == 13:
##                        self.battleScreen.blit(temp, [(192 - (self.attackSprite[self.frame].get_size()[0] / 2 )), (80 - (self.attackSprite[self.frame].get_size()[1]))])
##                    else:
##                        self.battleScreen.blit(temp, [0, 0])
##                elif OpponentAttack == True:
##                    if self.animNum == 0 or self.animNum == 1:
##                         self.battleScreen.blit(temp, [0, 20])
##                    elif self.animNum == 2:
##                        self.battleScreen.blit(temp, [-2, 40])
##                    elif self.animNum == 3:
##                        self.battleScreen.blit(temp, [-1, -1])
##                    elif self.animNum == 4:
##                        self.battleScreen.blit(temp, [0, 1])
##                    elif self.animNum == 5:
##                        self.battleScreen.blit(temp, [-1, 40])
##                    elif self.animNum == 6:
##                        self.battleScreen.blit(temp, [-40, 20])
##                    elif self.animNum == 7:
##                        self.battleScreen.blit(temp, [10,0])
##                    elif self.animNum == 8:
##                        self.battleScreen.blit(temp, [-3, 40])
##                    elif self.animNum == 9 or self.animNum == 12:
##                        self.battleScreen.blit(temp, [0, 0])
##                    elif self.animNum == 10:
##                        self.battleScreen.blit(temp, [-3, -40])
##                    elif self.animNum == 11:
##                        self.battleScreen.blit(temp, [-2, 50])
##                    elif self.animNum == 13:
##                        self.battleScreen.blit(temp, [75 - (self.pokeBackImage.get_size()[0] / 2), 140 - (self.pokeBackImage.get_size()[1] / 1.5)])                                      
#                
#                """ Would this work, I think it fixes some of the messy-e-ness
#                Spenser
#                
#                OLD WAY IS ABOVE
#                NEW WAY TO DO IT IS BELOW
#                """
#########################################
                
                
                if self.hpBars[0].cHealth != self.nHealth1:
                    PlayerAttack = False
                    OpponentAttack = True
                elif self.hpBars[1].cHealth != self.nHealth2:
                    PlayerAttack = True
                    OpponenetAttack = False
                    
                   
                thundaPos1 = ((192 - (self.attackSprite[self.frame].get_size()[0] / 2 )), (80 - (self.attackSprite[self.frame].get_size()[1])))
                thundaPos2 = (75 - (self.pokeBackImage.get_size()[0] / 2), 140 - (self.pokeBackImage.get_size()[1] / 1.5))
                
                if PlayerAttack == True:
                    coords1 = [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [-1, 40], [0, 0], [0, 0], [0, 0], [2, 0], [-2, -40], thundaPos1 ]
                    for i in coords1:
                        if self.animNum == i:
                            self.battleScreen.blit(temp, coords[i])       
                elif OpponentAttack == True:
                    coords2 = [[0, 20], [0, 20], [-2, 40], [-1, -1], [0, 1], [-1, 40], [-40, 20], [10, 0], [-3, 40], [0, 0], [0, 0], [-3, -40], [-2, 50], thudaPos2]
                    for j in coords2:
                        if self.animNum == j:
                            self.battleScreen.blit(temp, coords2[j])



#########################################    
                            
            elif self.animNum >= 14 or self.animNum <= 32:
                
                pass########## WORK ON THIS NEXT, AFTER CLEANING UP SETTING THE IMAGE
            
            
        if(self.currentAnim != "Attack"):
            topHealthBar = self.hpBars[0].getDisp()
            topHealthBar.set_colorkey((189, 189, 231))
            self.battleScreen.blit(topHealthBar, [battleScreenWidth - self.hpBars[0].mainGraphic.get_size()[0] + 1, battleScreenHeight - 5 - self.hpBars[0].mainGraphic.get_size()[1]])
            topHealthBar = self.hpBars[1].getDisp()
            topHealthBar.set_colorkey((189, 189, 231))
            self.battleScreen.blit(topHealthBar, [-3, 30])
        
        self.battleScreen = pygame.transform.scale2x(self.battleScreen)
        
        return self.battleScreen
    
    def newPokes(self, poke1, poke2):
        self.pokeBackImage = pygame.image.load("../images/back/" + str(poke1.ID) + ".png")
        self.hpBars[0].setNew(poke1.name, poke1.HP_stat[0], poke1.HP_stat[1], None)
        self.bottomPokePos = [64 - (self.pokeBackImage.get_size()[0] / 2), battleScreenHeight - (self.pokeBackImage.get_size()[1] / 1.5)]
        self.pokeFrontImage = pygame.image.load("../images/fronts/" + str(poke2.ID) + ".png")
        self.hpBars[0].setNew(poke2.name, poke2.HP_stat[0], poke2.HP_stat[1], None)
        self.topPokePos = [192 - (self.pokeFrontImage.get_size()[0] / 2 ), 95 - (self.pokeFrontImage.get_size()[1])]
    
    def newPoke(self, playNum, newPokeNum):
        if(playNum == 0):
            self.newPokeInfo = newPokeNum
            self.ticksLeft = POKESWITCHTICKS
            self.currentAnim = "BottomPokeOut"
            self.newPokeBackImage = pygame.image.load('../images/back/' + str(newPokeNum.ID) + '.png')
            self.exitRate = ((self.bottomPokePos[0] + self.pokeBackImage.get_size()[0]) // self.ticksLeft) + 1
        if(playNum == 1):
            self.newPokeInfo = newPokeNum
            self.ticksLeft = POKESWITCHTICKS
            self.currentAnim = "TopPokeOut"
            self.newPokeFrontImage = pygame.image.load('../images/fronts/' + str(newPokeNum.ID) + '.png')
            self.exitRate = (battleScreenWidth - self.topPokePos[0]) // self.ticksLeft + 1
            
    def newAttack(self, playNum, newHealth1, newHealth2, moveID, animRun = True):
        if(animRun == True):
            self.currentAnim = "Attack" 
            moveType = move.Move.type
            self.animNum = 8
            
             
         #                                  12                   10   4,8  11
            animNumList = [7, None, 6, None, 5, None, 3, 2, None, 0,   1,   9, 13, None, None, None, None]                          
            for h in self.typeListNums:
                if moveType == self.typeListNums[h]:
                    self.animNum = animNumList[h]
            if self.animNum == None:
                self.animNum = 8
                    

#            if moveType == self.typeList[1]:
#                self.animNum = 7 # +
#            elif moveType == self.typeList[2]:
#                self.animNum = 11
#            elif moveType == self.typeList[3]:
#                self.animNum = 6 # +
#            elif moveType == self.typeList[4]:
#                self.animNum = 11
#            elif moveType == self.typeList[5]:
#                self.animNum = 5 # + 12 +
#            elif moveType == self.typeList[6]:
#                self.animNum = 11
#            elif moveType == self.typeList[7]:
#                self.animNum = 3 # +
#            elif moveType == self.typeList[8]:
#                self.animNum = 2 # +
#            elif moveType == self.typeList[9]:
#                self.animNum = 11
#            elif moveType == self.typeList[10]:
#                self.animNum = 0 # + 10 +
#            elif moveType == self.typeList[11]:
#                self.animNum = 1 # + 4, 8 +
#            elif moveType == self.typeList[12]:
#                self.animNum = 9 # + 11 +
#            elif moveType == self.typeList[13]:
#                self.animNum = 13
#            elif moveType == self.typeList[14]:
#                self.animNum = 11
#            elif moveType == self.typeList[15]:
#                self.animNum = 11
#            elif moveType == self.typeList[16]:
#                self.animNum = 11
#            elif moveType == self.typeList[17]:
#                self.animNum = 11
            
                
            if self.animNum <= 13:
                self.attackForegroundImage = pygame.image.load('../images/attackAnimations/' + self.animation[self.animNum] + '.bmp')
        
            if(self.animationBackground[self.animNum] == "whiteBackground"):
                self.attackBackgroundImage = None
            else:
                self.attackBackgroundImage = pygame.image.load('../images/attackAnimations/' + self.animationBackground[self.animNum] + '.png')
            
            self.attackSprite = []
            self.xyflippedAttack = []
            self.xflippedAttack = []
            self.yflippedAttack = []

            for ROW in range(self.animationRow[self.animNum]):
                for COLUMN in range(self.animationColumn[self.animNum]):
                    nextFrame = pygame.Surface((self.animationWidth[self.animNum], self.animationHeightv2[self.animNum]))
                    nextFrame.blit(self.attackForegroundImage, (0, 0), (COLUMN * self.animationWidth[self.animNum], ROW * self.animationHeight[self.animNum], COLUMN * self.animationWidth[self.animNum] + (self.animationWidth[self.animNum] - 1), ROW * self.animationHeight[self.animNum] + (self.animationHeight[self.animNum] - 1)))
                    nextFrame.set_colorkey(self.animationColor[self.animNum])
                    self.attackSprite.append(nextFrame)
                    
                    xyflippedNextFrame = pygame.transform.flip(nextFrame, True, True)
                    self.xyflippedAttack.append(xyflippedNextFrame)
        
                    xflippedNextFrame = pygame.transform.flip(nextFrame, True, False)
                    self.xflippedAttack.append(xflippedNextFrame)
        
                    yflippedNextFrame = pygame.transform.flip(nextFrame, False, True)
                    self.yflippedAttack.append(yflippedNextFrame)

                    if(len(self.attackSprite) == self.animationFrames[self.animNum]):
                        break
                if(len(self.attackSprite) == self.animationFrames[self.animNum]):
                    break
            
            self.frame = 0
            
            self.playNum = playNum
            self.nHealth1 = newHealth1
            self.nHealth2 = newHealth2
            self.moveID = moveID
            self.ticksLeft = len(self.attackSprite) * 4
        else:
            self.nHealth1 = newHealth1
            self.nHealth2 = newHealth2
            if(self.hpBars[0].cHealth != self.nHealth1):
                self.ticksLeft = HEALTHBARTICKS
                self.currentAnim = "PlayerHealthBar"
                self.attackBackgroundImage = None
                self.attackForegroundImage = None
            elif(self.hpBars[1].cHealth != self.nHealth2):
                self.ticksLeft = HEALTHBARTICKS
                self.currentAnim = "OppHealthBar"
                self.attackBackgroundImage = None
                self.attackForegroundImage = None         

    def update(self):
        if(self.currentAnim == "Attack"):
            if(self.ticksLeft == 0):
                if(self.hpBars[0].cHealth != self.nHealth1):
                    self.ticksLeft = HEALTHBARTICKS
                    self.currentAnim = "PlayerHealthBar"
                    self.attackBackgroundImage = None
                    self.attackForegroundImage = None
                elif(self.hpBars[1].cHealth != self.nHealth2):
                    self.ticksLeft = HEALTHBARTICKS
                    self.currentAnim = "OppHealthBar"
                    self.attackBackgroundImage = None
                    self.attackForegroundImage = None
                else:
                    self.currentAnim = "Wait"
                    self.ticksLeft = PAUSETICKS
                    self.attackBackgroundImage = None
                    self.attackForegroundImage = None
            elif(self.ticksLeft % 4 == 0):
                if(self.frame > len(self.attackSprite) - 1):
                    self.ticksLeft = 0
                else:
                    if self.hpBars[0].cHealth != self.nHealth1:
                        PlayerAttack = False
                        OpponentAttack = True
                    elif self.hpBars[1].cHealth != self.nHealth2:
                        PlayerAttack = True
                        OpponenetAttack = False
                        
############################################################################################
                    if PlayerAttack == True:  
                        Fores1 = [self.attackSprite, self.attackSprite, self.attackSprite, self.attackSprite, self.attackSprite,
                                  self.attackSprite, self.xyflippedAttack, self.xyflippedAttack, self.attackSprite, self.attackSprite,
                                  self.attackSprite, self.attackSprite, self.xflippedAttack, self.attackSprite]
                        for k in Fores1:
                            if self.animNum == k:
                                self.attackForegroundImage = k[self.frame]    
                            if self.animNum == 13:
                                self.attackForegroundImage = pygame.transform.scale2x(self.attackForegroundImage)                  
                    elif OpponentAttack == True:
                        Fores2 = [self.xflippedAttack, self.xyflippedAttack, self.xyflippedAttack, self.xyflippedAttack, self.xflippedAttack,
                                  self.xflippedAttack, self.attackSprite, self.attackSprite, self.xyflippedAttack,  self.xyflippedAttack, 
                                  self.xflippedAttack, self.xflippedAttack, self.attackSprite, self.attackSprite]
                        for m in Fores2:
                            if self.animNum == m:
                                self.attackForeground = m[self.frame]
                            if self.animNum == 0:
                                pygame.transform.flip(self.attackBackgroundImage, True, True)
##############################################################################################                       
#                        
#                        
#'''        Me again. Would this work/is it what you meant by more efficent?
#            
#            
#            THIS TIME THE NEWER ONE IS ABOVE
#            AND THE OLDER LESS-EFFICENT IS BELOW
#            
#            P.S. There probably is a better way to create these lists without including the 'self.' in front of everything,
#                 but i think that if i were to put self.attackForeground = self.Fores1[m] it would give me an error. 
#                 Would this happen? Also, would it happen if i were to take the self.frame out of the list,
#                 for example, would ---  self.attackForeground = Fores2[m][self.frame] -- work? 
#                 Or would the extra bracket give an error?
#                 
#                P.S.p.s --- Since there is a self.frame += 1 outside the for loops, would i have to take the [self.frame] 
#                            off the variables in these lists and put it after the Fores2[m] making it Fores2[m][self.frame]?
#                            Or would i have to put a self.frame += 1 inside of each of the "for" loops?
#                 
#            Thanks a lot,
#            Spenser
#'''
#                        
##                    if PlayerAttack == True:  
##                        if self.animNum == 0 or self.animNum == 1:
##                            self.attackForegroundImage = self.attackSprite[self.frame]
##                        elif self.animNum == 6:
##                            self.attackForegroundImage = self.xyflippedAttack[self.frame]
##                        elif self.animNum == 7:
##                            self.attackForegroundImage = self.xyflippedAttack[self.frame]
##                        elif self.animNum == 11:
##                            self.attackForegroundImage = self.attackSprite[self.frame] 
##                        elif self.animNum == 12:
##                            self.attackForegroundImage = self.xflippedAttack[self.frame]
##                        elif self.animNum == 13:
##                            self.attackForegroundImage = self.attackSprite[self.frame] 
##                            self.attackForegroundImage = pygame.transform.scale2x(self.attackForegroundImage)
##                        else:
##                            self.attackForegroundImage = self.attackSprite[self.frame]
##                            
##                    elif OpponentAttack == True:
##                        if self.animNum == 0:
##                            self.attackForegroundImage = self.xflippedAttack[self.frame] 
##                            pygame.transform.flip(self.attackBackgroundImage, True, True)
##                        elif self.animNum == 1:
##                            self.attackForegroundImage = self.xyflippedAttack[self.frame] 
##                        elif self.animNum == 2:
##                            self.attackForegroundImage = self.xyflippedAttack[self.frame] 
##                        elif self.animNum == 3:
##                            self.attackForegroundImage = self.xyflippedAttack[self.frame] 
##                        elif self.animNum == 4:
##                            self.attackForegroundImage = self.xflippedAttack[self.frame]
##                        elif self.animNum == 5:
##                            self.attackForegroundImage = self.xflippedAttack[self.frame] 
##                        elif self.animNum == 6:
##                            self.attackForegroundImage = self.attackSprite[self.frame]
##                        elif self.animNum == 7:
##                            self.attackForegroundImage = self.attackSprite[self.frame] 
##                        elif self.animNum == 8:
##                            self.attackForegroundImage = self.xyflippedAttack[self.frame] 
##                        elif self.animNum == 9:
##                            self.attackForegroundImage = self.xyflippedAttack[self.frame] 
##                        elif self.animNum == 10:
##                            self.attackForegroundImage = self.xflippedAttack[self.frame]
##                        elif self.animNum == 11:
##                            self.attackForegroundImage = self.xflippedAttack[self.frame] 
##                        elif self.animNum == 12:
##                            self.attackForegroundImage = self.attackSprite[self.frame] 
##                        elif self.animNum == 13:
##                            self.attackForegroundImage = self.attackSprite[self.frame] 
                                
                    self.frame += 1
            self.ticksLeft -= 1
        elif(self.currentAnim == "Wait"):
            if(self.ticksLeft == 0):
                self.currentAnim = "None"
                return True
            self.ticksLeft -= 1
        elif(self.currentAnim == "PlayerHealthBar"):
            if(self.ticksLeft == 0):
                if(self.hpBars[1].cHealth != self.nHealth2):
                    self.ticksLeft = HEALTHBARTICKS
                    self.currentAnim = "OppHealthBar"
                else:
                    self.currentAnim = "Wait"
                    self.ticksLeft = PAUSETICKS
                    return
            rate = (self.hpBars[0].cHealth - self.nHealth1) // self.ticksLeft
            self.hpBars[0].updateHealth(self.hpBars[0].cHealth - rate)
            self.ticksLeft -= 1
        elif(self.currentAnim == "OppHealthBar"):
            if(self.ticksLeft == 0):
                self.currentAnim = "Wait"
                self.ticksLeft = PAUSETICKS
                return
            rate = (self.hpBars[1].cHealth - self.nHealth2) // self.ticksLeft
            self.hpBars[1].updateHealth(self.hpBars[1].cHealth - rate)
            self.ticksLeft -= 1
        elif(self.currentAnim == "BottomPokeOut"):
            if(self.ticksLeft == 0):
                self.ticksLeft = POKESWITCHTICKS
                self.pokeBackImage = self.newPokeBackImage
                self.bottomPokePos = [-self.pokeBackImage.get_size()[0], battleScreenHeight - (self.pokeBackImage.get_size()[1] / 1.5)]
                self.bottomPokePosF = [64 - (self.pokeBackImage.get_size()[0] / 2), battleScreenHeight - (self.pokeBackImage.get_size()[1] / 1.5)]
                self.enterRate = (self.bottomPokePosF[0] - self.bottomPokePos[0]) // 30
                self.currentAnim = "BottomPokeIn"
                self.hpBars[0].setNew(self.newPokeInfo.name, self.newPokeInfo.HP_stat[0], self.newPokeInfo.HP_stat[1], None)
            self.bottomPokePos = [self.bottomPokePos[0] - self.exitRate, self.bottomPokePos[1]]
            self.ticksLeft -= 1
        elif(self.currentAnim == "BottomPokeIn"):
            self.bottomPokePos = [self.bottomPokePos[0] + self.enterRate, self.bottomPokePos[1]]
            self.ticksLeft -= 1
            if(self.ticksLeft == 0):
                self.bottomPokePos = self.bottomPokePosF
                self.currentAnim = "None"
                return True
            self.enterRate = (self.bottomPokePosF[0] - self.bottomPokePos[0]) // self.ticksLeft
        elif(self.currentAnim == "TopPokeOut"):
            if(self.ticksLeft == 0):
                self.ticksLeft = POKESWITCHTICKS
                self.pokeFrontImage = self.newPokeFrontImage
                self.topPokePos = [battleScreenWidth, 95 - (self.pokeFrontImage.get_size()[1])]
                self.topPokePosF = [192 - (self.pokeFrontImage.get_size()[0] / 2 ), 95 - (self.pokeFrontImage.get_size()[1])]
                self.enterRate = (self.topPokePosF[0] - self.topPokePos[0]) // self.ticksLeft
                self.hpBars[1].setNew(self.newPokeInfo.name, self.newPokeInfo.HP_stat[0], self.newPokeInfo.HP_stat[1], None)
                self.currentAnim = "TopPokeIn"
            self.topPokePos = [self.topPokePos[0] + self.exitRate, self.topPokePos[1]]
            self.ticksLeft -= 1
            return False
        elif(self.currentAnim == "TopPokeIn"):
            self.topPokePos = [self.topPokePos[0] + self.enterRate, self.topPokePos[1]]
            self.ticksLeft -= 1
            if(self.ticksLeft == 0):
                self.topPokePos = self.topPokePosF
                self.currentAnim = "None"
                return True
            self.enterRate = (self.topPokePosF[0] - self.topPokePos[0]) // self.ticksLeft
        elif(self.currentAnim == "None"):
            return True
        return False
